/**
  ******************************************************************************
  * @file    gt32f030_beep.c
  * @author  GT Application Team
  * @version V1.0.0
  * @date    03-January-2025      
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT 2022 Giantec Semicondutor Inc</center></h2>
  *
  *             http://www.giantec-semi.com/
  *
  * Unless required by applicable law or agreed to in writing, software 
  * distributed under the License is distributed on an "AS IS" BASIS, 
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  *
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include "gt32f030_rcc.h"
#include "gt32f030_beep.h"

 /** @addtogroup GT32F030_StdPeriph_Driver
  * @{
  */
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
#define  BEEP_CSR_ENABLE  ((unsigned int)0x00040000)


/** @defgroup BEEP 
  * @brief BEEP driver modules
  * @{
  */ 

/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/

/** @defgroup BEEP_Private_Functions
  * @{
  */ 

/** @defgroup BEEP_Init Initialization functions
 *  @brief   Initialization and functions
 *
@verbatim    
 ===============================================================================
              ##### Initialization functions #####
 ===============================================================================
@endverbatim
  * @{
  */
/**
  * @brief  Deinitializes the BEEP peripheral registers to their default reset values.
  * @param  None
  * @retval None
  */
void BEEP_DeInit(void)
{
	RCC_PeriphResetCmd(RCC_PeriphReset_BEEP, ENABLE);
	RCC_PeriphResetCmd(RCC_PeriphReset_BEEP, DISABLE);
}

/**
  * @brief  Initializes the BEEP peripheral according to the specified
  *         parameters in the BEEP_InitStruct .
  * @param  BEEP_InitStruct: pointer to a BEEP_InitTypeDef structure that contains
  *         the configuration information.
  * @retval None
  */
void BEEP_Init(BEEP_InitTypeDef* BEEP_InitStruct)
{
	/* Check the parameters */
  assert_param(IS_BEEP_CLKSRC(BEEP_InitStruct->BEEP_ClkSource));
  assert_param(IS_BEEP_CLKOPRESCALE(BEEP_InitStruct->BEEP_CLKOutputPreScale)); 
  assert_param(IS_BEEP_OUTPUTDIV(BEEP_InitStruct->BEEP_Div));
 
  /*---------------------------- BEEP CSR Configuration -----------------*/
  BEEP->CSR   = (BEEP_InitStruct->BEEP_ClkSource<<20)         | \
	              (BEEP_InitStruct->BEEP_CLKOutputPreScale<<16) | \
	              (BEEP_InitStruct->BEEP_OutputDiv);
}

/**
  * @brief  Fills each BEEP_InitStruct member with its default value.
  * @param  BEEP_InitStruct: pointer to a BEEP_InitTypeDef structure
  *         which will be initialized.
  * @retval None
  */
void BEEP_StructInit(BEEP_InitTypeDef* BEEP_InitStruct)
{
	BEEP_InitStruct->BEEP_ClkSource         = BEEP_ClkSource_LIRC;
	BEEP_InitStruct->BEEP_CLKOutputPreScale = BEEP_CLKOutput_PreScale8;
	BEEP_InitStruct->BEEP_OutputDiv         = 0x00;
}
/**
  * @}  
  */ 

/** @defgroup BEEP_OpCfg Operation and Configuration functions
 *  @brief   Operation and Configuration functions
 *
@verbatim   
 ===============================================================================
           ##### Operation and Configuration functions #####
 ===============================================================================  
@endverbatim
  * @{
  */
/**
  * @brief  Enables or disables the BEEP .
  * @param  NewState: new state of the BEEP.
  *         This parameter can be: ENABLE or DISABLE.
  * @retval None
  */
void BEEP_Cmd(FunctionalState NewState)
{
  /* Check the parameters */
  assert_param(IS_FUNCTIONAL_STATE(NewState));

  if (NewState != DISABLE)
  {
    BEEP->CSR |= BEEP_CSR_ENABLE;
  }
  else
  {
    BEEP->CSR &= ~BEEP_CSR_ENABLE;
  }	
}
/**
  * @}  
  */ 

/**
  * @}  
  */

/**
  * @}  
  */ 

/**
  * @}
  */ 
/************************ (C) COPYRIGHT Giantec Semicondutor Inc *****END OF FILE****/
